package com.wc.alorithm_luogu.P1200;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/23 19:39
 * @description https://www.luogu.com.cn/problem/P1200
 * 你的飞碟在这儿Your Ride Is Here
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String star = sc.nextLine();
        int starNum = 1;
        String group = sc.nextLine();
        int groupNum = 1;

        for (char ch : star.toCharArray()) {
            starNum *= ch - 'A' + 1;
        }
        for (char ch : group.toCharArray()) {
            groupNum *= ch - 'A' + 1;
        }
        if (starNum % 47 == groupNum % 47) {
            System.out.println("GO");
        } else {
            System.out.println("STAY");
        }
    }
}
